<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page errorPage="../errorPage.jsp" %>
<c:if test="${empty sessionScope.user}">
	<c:redirect url="../login.jsp" />
</c:if>
<c:if test="${sessionScope.user.getClass().name != 'accountManagement.Client' and sessionScope.user.getClass().name != 'accountManagement.Employee'}">
	<jsp:forward page="../errorPage.jsp">
		<jsp:param name="error" value="Access not permitted!" />
	</jsp:forward>
</c:if>
<c:if test="${empty transport or empty earnings}">
	<jsp:forward page="../errorPage.jsp">
		<jsp:param name="error" value="Wrong access to page!" />
	</jsp:forward>
</c:if>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="ISO-8859-1">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/template.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/header.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/footer.css">
		<title>Dettagli corsa ricercata</title>
	</head>
	
	<body>
		<div id="body">
			<%@ include file="../header.jsp" %>
			
			<%@ include file="../menu.jsp" %>
			
			<div id="title">
				Dettagli corsa: <c:out value="${transport.transportId}" />
			</div>
			
			<div id="content">
				<div>
					<div>
						Luogo Partenza: <span class="bold"><c:out value=" ${transport.origin}" /></span>
					</div>
					<div>
						Luogo Arrivo: <span class="bold"><c:out value=" ${transport.destination}" /></span>
					</div>
					<div>
						Data Partenza: <span class="bold"><c:out value=" ${transport.departureDate}" /></span>
					</div>
					<div>
						Data Arrivo: <span class="bold"><c:out value=" ${transport.arrivalDate}" /></span>
					</div>
					<div>
						Prezzo: <span class="bold"><c:out value=" ${transport.seatPrize}" /></span>
					</div>
				</div>
				
				<c:if test="${sessionScope.user.getClass().name == 'accountManagement.Employee'}">
			    	<div>
						<div>
							Incasso: <span class="bold"><c:out value="${earnings}" /></span>
						</div>
					</div>
				</c:if>
				
				<c:if test="${sessionScope.user.getClass().name == 'accountManagement.Client'}">
					<div>
						<form action="${pageContext.request.contextPath}/ServletBuyTicket" method="post">
							<div>
								<input type="hidden" id="type" name="type" value="ticket">
								<input type="hidden" id="transportId" name="transportId" value="${transport.transportId}">
								<input type="submit" value="Acquista Biglietto">
							</div>
						</form>
					</div>
				
				    <div>
						<form action="${pageContext.request.contextPath}/ServletBuyTicket" method="post">
							<div>
								<label>Data inizio:</label>
								<input type="text" id="beginDate" name="beginDate">
							</div>
							<div>
								<label>Data fine:</label>
								<input type="text" id="endDate" name="endDate">
							</div>
							<div>
								<input type="hidden" id="type" name="type" value="seasonTicket">
								<input type="hidden" id="transportId" name="transportId" value="${transport.transportId}">
								<input type="submit" value="Acquista Abbonamento">
							</div>
						</form>
					</div>
				</c:if>
				
				<c:if test="${sessionScope.user.getClass().name == 'accountManagement.Employee'}">
			    	<div>
						<form action="${pageContext.request.contextPath}/ServletEditTransportPrize" method="post">
							<div>
								<input type="text" id="newSeatPrize" name="newSeatPrize">
							</div>
							<div>
								<input type="hidden" id="transportId" name="transportId" value="${transport.transportId}">
								<input type="submit" id="editPrice" name="editPrice" value="Modifica prezzo">
							</div>
						</form>
					</div>
					<div>
						<form action="${pageContext.request.contextPath}/ServletRemoveTransport" method="post">
							<div>
								<input type="hidden" id="transportId" name="transportId" value="${transport.transportId}">
								<input type="submit" id="remove" name="remove" value="Elimina corsa">
							</div>
						</form>
					</div>
				</c:if>
			</div>
			
			<%@ include file="../footer.jsp" %>
		</div>
	</body>
</html>